package whf.framework.security.service;

import whf.framework.exception.CreateException;
import whf.framework.exception.ServiceNotFoundException;
import whf.framework.security.dao.DeptDAO;
import whf.framework.security.entity.Dept;
import whf.framework.util.BeanFactory;
import whf.framework.util.StringUtils;

/**
 * @author wanghaifeng
 * @email king@126.com
 * @modify 2006-07-06
 */
public class DeptServiceImp extends whf.framework.service.ServiceImp<Dept> implements DeptService {
	/**
	 * @modify wanghaifeng Sep 11, 2006 10:27:15 PM
	 * @param deptDAO
	 */
	public void setDeptDAO(DeptDAO deptDAO) {
		this.entityDAO = deptDAO;
	}

	public static DeptService getDeptService() throws ServiceNotFoundException {
		return (DeptService)BeanFactory.getService(DeptServiceImp.class) ;
	}

	@Override
	public void create(Dept entity) throws CreateException {
		Dept parent = entity.getParent();
		if(parent != null && StringUtils.isEmpty(entity.getBranch())) {
			entity.setBranch(parent.getBranch());
		}
		super.create(entity);
	}

} 